<?php

namespace app\admin\validate;
use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'name'  =>  'require|length:6,16|unique:admin',
        'password' =>  'require|length:6,16',
        'newpassword' => 'require|length:6,16',
        'repassword' => 'require|confirm:newpassword',
    ];

    protected $message  =   [
        'name.require' => '用户名必须填写',
        'name.length'  => '用户名长度必须在6至16位之间', 
        'name.unique'  => '用户名已经存在了',
        'password.require' => '密码不允许为空',
        'password.length' => '密码长度必须在6至16位之间',
        'newpassword.require' => '新密码必须输入',
        'newpassword.length' => '新密码长度必须在6至16位之间',
        'repassword.require' => '必须再次确认新密码',
        'repassword.confirm' => '俩次输入密码不一致'
    ];
    
    protected $scene = [
        'add'  =>  ['name','password'],
        'edit'  => ['name','password','newpassword','repassword'],
    ];
    

}